<template>
	<view class="page-index">
		<view class="box">
			<view class="box-hd">
				<view class="box-hd-label">门诊缴费(医保)</view>
				<view class="box-hd-value">
					<span class="col_g" v-if="orderDetail.orderStatu == 1">交易成功</span>
					<span class="col_r" v-else>订单异常</span>
				</view>
			</view>
			<view class="box-bd">
				<view class="box-item">
					<view class="box-bd-label">缴费医院：</view>
					<view class="box-bd-value">{{currentHospital}}</view>
				</view>
				<view class="box-item">
					<view class="box-bd-label">订单编号：</view>
					<view class="box-bd-value">{{orderDetail.orderNum}}</view>
				</view>
				<view class="box-item">
					<view class="box-bd-label">消费卡号：</view>
					<view class="box-bd-value">{{bhS}}****************{{bhE}}</view>
				</view>
				<view class="box-item">
					<view class="box-bd-label">交易类型：</view>
					<view class="box-bd-value">门诊缴费(医保)</view>
				</view>
				<view class="box-item">
					<view class="box-bd-label">消费来源：</view>
					<view class="box-bd-value">微信</view>
				</view>
				<view class="box-item">
					<view class="box-bd-label">交易金额：</view>
					<view class="box-bd-value">
						<span class="col_r">{{orderDetail.orderAmount}}元</span>
					</view>
				</view>
				<view class="box-item">
					<view class="box-bd-label">消费日期：</view>
					<view class="box-bd-value">{{orderDetail.payTime}}</view>
				</view>
			</view>
		</view>
			
	</view>
</template>

<script>
	import {
		encrypt,
		decrypt
	} from '@/utils/sm4Util.js'
	import { getOrderByOpenId } from "@/api/pay/index.js"
	export default {
		name: 'OrderDetail',
		data() {
			return {
				currentHospital: {
					name: '',
					hospitalCode: ''
				},
				orderDetail: {}, //缴费明细
				openid: '',
				bhS:'',
				bhE:'',
			}
		},
		created() {
			let openid = uni.getStorageSync('openid') || ''
			this.openid = openid
			uni.showLoading({
				title: '加载中',
				mask: true,
			});
			this.getOrderDetail();
			let hospital = uni.getStorageSync('hospital');
			this.currentHospital = JSON.parse(hospital).name;
		},
		onLoad(options) {
			// let openid = uni.getStorageSync('openid') || ''
			// this.openid = openid
			// uni.showLoading({
			// 	title: '加载中',
			// 	mask: true,
			// });
			// this.getOrderDetail();
			// let hospital = uni.getStorageSync('hospital');
			// this.currentHospital = JSON.parse(hospital);
		},
		methods: {
			// 获取缴费详情
			getOrderDetail() {
				getOrderByOpenId({
					openId: this.openid,
				}).then(res => {
					uni.hideLoading();
					if (res.code == 200) {
						this.orderDetail = res.data;
						if(res.data.bh){
							this.bhS = res.data.bh[0];
							this.bhE = res.data.bh[res.data.bh.length-1];
						}
					} else {
						this.$msg(res.msg);
					}
				});
			},
		}
	}
</script>

<style scoped>
	@import './index.css';
</style>